using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Fieldbook.Entities;
using Fieldbook.DAL;
using System.Diagnostics;

namespace Fieldbook.NUnitTests.Fieldbook.DAL
{
    [TestFixture]
    public class MeasureUnitTestDAO : DAOTest
    {

        [Test]
        public void AddMeasureUnitTest()
        {
            Exception exc = null;
            try
            {
                Measureunit unit = GetTestMeasureUnit();
                unit.Categoryid = Measureunit.MeasureCategory.Area;
                MeasureunitDAO.InsertMeasureunit(unit);
                Assert.IsNotNull(unit.Measureunitid);

                List<int> ids = MeasureunitDAO.GetMeasureUnitIds(String.Format(" WHERE MeasureUnitID = {0} ", (int)unit.Measureunitid));
                Assert.AreEqual(ids.Count, 1);
                MeasureunitDAO.DeleteMeasureunit(unit);
                ids = MeasureunitDAO.GetMeasureUnitIds(String.Format(" WHERE MeasureUnitID = {0} ", (int)unit.Measureunitid));
                Assert.AreEqual(ids.Count, 0);
            }
            catch (Exception ex)
            {
                Trace.Write(ex);
                exc = ex;
            }
            Assert.IsNull(exc);

        }
    }
}
